Skip to content

Upgrade Font Awesome from 5.1.0 to 5.7.2#713

Merged
yamgent merged 6 commits into
MarkBind:masterfrom
Xenonym:assets/upgrade-fontawesome-5.7.2
Mar 11, 2019
Merged

Upgrade Font Awesome from 5.1.0 to 5.7.2#713
yamgent merged 6 commits into
MarkBind:masterfrom
Xenonym:assets/upgrade-fontawesome-5.7.2

Conversation

@Xenonym

@Xenonym Xenonym commented Feb 19, 2019

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] Enhancement to an existing feature

Fixes #510.

What is the rationale for this request?
With #680, Font Awesome icon names no longer need to be manually hardcoded to be used when referenced with the new colon syntax. As such, we can straightforwardly upgrade our version of Font Awesome by just replacing the CSS and font files. We can also use the @fortawesome/fontawesome-free NPM package to keep Font Awesome updated in the future.

What changes did you make? (Give an overview)

  • I installed @fortawesome/fontawesome-free@5.7.2.
  • I moved the Glyphicon asset files into asset/glyphicons/, to avoid having fonts/ (from Glyphicons) and webfonts/ (from Font Awesome) in the same folder.
  • I added Site.js#copyFontAwesomeAsset to copy Font Awesome files from the NPM package to asset/fontawesome/.
  • I fixed the behavior of the fs.copyAsync() mock to match its actual behaviour (details in 8e438cb)

Provide some example code that this change will affect:

- FA new icons: :fab-markdown: :fas-biohazard:

Testing instructions:

  1. Add the above example code to a MarkBind site. It should render the new FA icons:

New FA icons

@acjh

acjh commented Feb 19, 2019

Copy link
Copy Markdown
Contributor

Why are glyphicons affected?

@Xenonym

Xenonym commented Feb 19, 2019

Copy link
Copy Markdown
Contributor Author

Why are glyphicons affected?

@acjh I shifted fonts/ to webfonts/ and edited the Glyphicon CSS files to match as the new FA files use webfonts/. Since we will update FA but not Glyphicons in the future, changing the directory structure to match FA's should be more efficient.

@acjh

acjh commented Feb 19, 2019

Copy link
Copy Markdown
Contributor

What's more efficient? Glyphicons and Font Awesome use separate files right?

@Xenonym

Xenonym commented Feb 19, 2019

Copy link
Copy Markdown
Contributor Author

What's more efficient? Glyphicons and Font Awesome use separate files right?

@acjh Right, efficient may not be the right choice of word. What I meant was, the new FA files use webfonts/, while Glyphicons uses fonts/. Since it would be confusing to have both webfonts/ and fonts/, I decided to consolidate both font folders. I chose to change the Glyphicons CSS files to refer to webfonts/ instead of changing the FA CSS files to use fonts/ since we will be likely to do FA upgrades in the future, and changing the Glyphicons CSS files once would be more "efficient" for upgrading than to change the FA CSS files to refer to fonts/ every time.

On the flip side, since Glyphicons are no longer in Bootstrap, it is unlikely that we would have to change out those files in the future as there is no longer a publicly available version of Glyphicons beyond what used to be in Bootstrap.

@acjh

acjh commented Feb 19, 2019

Copy link
Copy Markdown
Contributor

Let's not change the original paths.
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css

Also, shall we use npm to manage Font Awesome?
https://fontawesome.com/how-to-use/on-the-web/setup/using-package-managers

@Xenonym

Xenonym commented Feb 20, 2019

Copy link
Copy Markdown
Contributor Author

Let's not change the original paths.

👍 Might I suggest doing assets/fontawesome/ and assets/glyphicons? I feel that having both webfonts/ and fonts/ in the same folder will lead to confusion in the future.

Also, shall we use npm to manage Font Awesome?

This seems like a good idea, but we would need to change our asset logic to copy from both assets/ and the NPM package. Also, currently we bundle ~2MB of FA asset files with the package, but to use the NPM package would involve ~13MB, which is a not-insignificant size bump.

@yamgent

yamgent commented Feb 21, 2019

Copy link
Copy Markdown
Member

This seems like a good idea, but we would need to change our asset logic to copy from both assets/ and the NPM package. Also, currently we bundle ~2MB of FA asset files with the package, but to use the NPM package would involve ~13MB, which is a not-insignificant size bump.

The size bump is only on the MarkBind application side right? When we build the website, we may not need the entire package, we can just copy their webfonts/ folder?

Using an npm package may also make upgrading the icons more convenient in the future.

@Xenonym

Xenonym commented Feb 21, 2019

Copy link
Copy Markdown
Contributor Author

The size bump is only on the MarkBind application side right? When we build the website, we may not need the entire package, we can just copy their webfonts/ folder?

Yes, that's right. The 13 MB is just an increase in size when a user installs MarkBind. However, built sites will still be the same size.

Using an npm package may also make upgrading the icons more convenient in the future.

Agreed. However, I was wondering if the benefit of this outweighs the increase in install size? (given that we don't use most of the Font Awesome package apart from the pre-built files)

@yamgent

yamgent commented Feb 22, 2019

Copy link
Copy Markdown
Member

Agreed. However, I was wondering if the benefit of this outweighs the increase in install size? (given that we don't use most of the Font Awesome package apart from the pre-built files)

Hmm, I agree that it makes our app a bit more bloated. @Chng-Zhi-Xuan what do you think?

@Chng-Zhi-Xuan

Chng-Zhi-Xuan commented Feb 22, 2019

Copy link
Copy Markdown
Contributor

I think going forward to update Font Awesome automatically is necessary, especially if it can reduce manual labour.

MarkBind as a product is also operating under some assumptions of our users:

  • The author is using it on a computer
  • Has reasonable internet access

So the 13MB increase in install size is quite trivial given that a 1 minute 720P YouTube video is approximately 40MB already.

@Xenonym

Xenonym commented Feb 23, 2019

Copy link
Copy Markdown
Contributor Author

I shall try to see how to upgrade Font Awesome with the NPM package then!
Should I create another PR for that?

@Chng-Zhi-Xuan

Copy link
Copy Markdown
Contributor

Should I create another PR for that?

Putting it in this PR is ok.

@Xenonym

Xenonym commented Mar 5, 2019

Copy link
Copy Markdown
Contributor Author

This PR has been updated to use Font Awesome via the NPM package!

@yamgent yamgent self-requested a review March 6, 2019 04:18
@yamgent

yamgent commented Mar 8, 2019

Copy link
Copy Markdown
Member

I will take a closer look when I get home at night, but generally I haven't spotted a big issue yet.

Meanwhile,

  1. "Move glyphicon files to asset/glyphicons" commit should be wrapped at 72 characters. Also maybe clean the commit message a bit, by writing a standard paragraph rather than using a bullet point?

Comment thread src/Site.js
Comment thread __mocks__/fs-extra-promise.js Outdated
Xenonym added 4 commits March 9, 2019 00:41
Font Awesome stores fonts in webfonts/, while Glyphicons stores fonts
in fonts/. To avoid confusion between these two similarly named
folders, let's shift Glyphicon files to asset/glyphicons/.
fs-extra-promise#copyAsync creates folders along the destination
if they do not already exist. For example:

fse.copyAsync('file.txt', 'does/not/exist/dest.txt')

will succeed and create the folders "does", "not" and "exist". This
is different from the behaviour of fs.copyFileSync, which raises an
error as the destination folder does not exist. Thus, our test mocks
for copyAsync are incorrect as they rely on the mock for copyFileSync.

Let's create new mocks for copyAsync and copyDirAsync such that their
behaviour matches that of the actual copyAsync.
@Xenonym

Xenonym commented Mar 8, 2019

Copy link
Copy Markdown
Contributor Author

@yamgent commit messages updated!

@yamgent

yamgent commented Mar 10, 2019

Copy link
Copy Markdown
Member

@yamgent commit messages updated!

Nice work. 👍

Only one minor nit, for commit message in "Copy Font Awesome assets from NPM package", you can drop the word "Currently", it is implied.

For commit message in "Return promise directly from copyMarkbindAsset", we could have avoided using the uncommonly heard jargon, by directly explaining the problem with the anti-pattern (the original code is an exercise in futility), but the diff speaks for itself so I am open with leaving the message as it is now.

Xenonym added 2 commits March 11, 2019 02:47
- Remove explicit promise construction anti-pattern:
https://stackoverflow.com/a/23803744
We include Font Awesome assets by manually copying them to our own
package. Since Font Awesome maintains an NPM package, we should copy
Font Awesome assets from the NPM package assets for easier maintainence
in the future.

Let's remove the existing Font Awesome assets in the MarkBind
directory and copy them from the NPM package. We should also copy
them to _markbind/fontawesome, to prevent confusion with Glyphicon
assets.

@Chng-Zhi-Xuan Chng-Zhi-Xuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@yamgent yamgent added this to the v1.19.4 milestone Mar 11, 2019
@yamgent yamgent merged commit 851b7a0 into MarkBind:master Mar 11, 2019
@Xenonym Xenonym deleted the assets/upgrade-fontawesome-5.7.2 branch March 11, 2019 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

{{ fab_markdown }} is not working

4 participants